package org.egrit.util;

import java.awt.Point;
import java.util.Random;

import org.egrit.IGridBounds;

/**
 *
 * @author michael
 */
public class RandomGridPos {
    
    private final Random RANDOM;

    public RandomGridPos() {
        this(new Random());
    }

    public RandomGridPos(Random RANDOM) {
        this.RANDOM = RANDOM;
    }
    
    public Point getRandomPos(IGridBounds bounds) {
        Args.notNull("bounds", bounds);
        
        if (bounds.isEmpty()) {
            return new Point();
        }
        
        int x = RANDOM.nextInt(bounds.getWidth()) + bounds.getMinGridX();
        int y = RANDOM.nextInt(bounds.getHeight()) + bounds.getMinGridY();
        return new Point(x, y);
    }
    
}
